package com.wonderful.compose.navigation

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import com.wonderful.compose.ui.theme.ComposeLearnTheme

/**
 * Describe: 使用State实现页面跳转，但无导航能力
 *
 * @author Wonderful
 * @time 2025/9/16 09:31
 */
class UseStateNavActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            ComposeLearnTheme {
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    UseStateNav()
                }
            }
        }
    }
}

@Composable
fun UseStateNav(modifier: Modifier = Modifier) {
    var currentScreen by remember { mutableStateOf(0) }
    when (currentScreen % 3) {
        0 -> ScreenA { currentScreen++ }
        1 -> ScreenB { currentScreen++ }
        2 -> ScreenC { currentScreen++ }
    }
}


